﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Salats
{
    interface ILogger
    {
        void Log (Salat Slt);
    }

    public class ConLogger : ILogger
    {
        public void Log(Salat Slt)
        {
            ArrayList a = Slt.salat;

            for (int i = 0; i < a.Count; i++)
            {
                Console.WriteLine(((AbstractVegetable)a[i]).GetType() + " - " + ((AbstractVegetable)a[i]).GetName() + " (" + ((AbstractVegetable)a[i]).GetCalorie() + ")");
            }
        }
    }

    public class FileLogger : ILogger
    {
        public void Log(Salat Slt)
        {
            ArrayList a = Slt.salat;
            string[] s = new string[a.Count];

            for (int i = 0; i < a.Count; i++)
            {
                s[i] = ((AbstractVegetable)a[i]).GetType() + " - " + ((AbstractVegetable)a[i]).GetName() + " (" + ((AbstractVegetable)a[i]).GetCalorie() + ")";
            }

            System.IO.File.WriteAllLines(@"salats.txt", s);
            

        }

    }
}
